package search

import (
    "strings"
    "fmt"
    "http"
    "io/ioutil"
    "json"
)
func solrQuery(query string) string{
    s := "http://localhost:8983/solr/select/?wt=json&"+query
    r,_,_ := http.Get(s)
    b,_:=ioutil.ReadAll(r.Body)
    r.Body.Close()
    return string(b)
}
type Mapable interface{
    GetMap() map[string]string
}


func postSolr(bcv Mapable) {
    bcvString,_ := json.Marshal(bcv.GetMap())
    data := fmt.Sprintf("{\"add\": { \"doc\": %s } }",bcvString)
    location := "http://localhost:8983/solr/update/json?commit=true"
    r,_ :=http.Post(location,"text/json",strings.NewReader(data))
    ioutil.ReadAll(r.Body)
    r.Body.Close()
}

